package com.zzyd.factory.account;

import android.util.Log;

import com.zzyd.common.mvp.data.DataSource;
import com.zzyd.common.mvp.presenter.BasePresenter;
import com.zzyd.factory.model.account.User;
import com.zzyd.factory.net.account.AccountDataHelper;

import java.util.HashMap;
import java.util.Map;

/**
 * @author wjunjie
 * @version 1.0
 * @E-mail wang_junjie007@163.com
 * @company ZZYD
 * @createTime 2018/7/20 15:38
 * @类注释:
 */
public class LoginPresenter extends BasePresenter<LoginContract.View> implements LoginContract.Persenter,DataSource.CallBack<User> {


    public LoginPresenter(LoginContract.View view) {
        super(view);
    }

    @Override
    public void login(String name, String password) {
        start();
        Map<String,String> map=new HashMap<>();
        map.put("loginName",name);
        map.put("password",password);
        map.put("version","1.0");
        Log.e("user","01");
        AccountDataHelper.login(map,this);
    }

    @Override
    public void onDataLoaded(User user) {
        LoginContract.View view = getView();
        if (user!=null&&user.getCode()==200){
            view.loginSuccess();
        }
    }

    @Override
    public void onDataNotAvailable(int str) {

    }
}
